package tep;

import java.util.ArrayList;

public class ch5 {
    static ArrayList<ArrayList<Integer>> list = new ArrayList<>();
    static ArrayList<Integer> l = new ArrayList<>();

    public static void backtrack(int index,int[] arr){
        list.add(new ArrayList<>(l));

        for(int i=index;i<arr.length;i++){
            l.add(arr[i]);
            backtrack(i+1,arr);
            l.remove(l.size()-1);

        }



    }


    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3};
        backtrack(0,arr);
        System.out.println("----");
        for(ArrayList<Integer> list:list){
            for(int i=0;i<list.size();i++){
                System.out.print(list.get(i)+" ");
            }
            System.out.println(" ");
        }

    }
}
